package com.deyuanyun.pic.ctrl.controller;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.deyuanyun.pic.common.util.DateUtil;
import com.deyuanyun.pic.pipe.controller.BaseController;
import com.deyuanyun.pic.pipe.util.ExportExcel;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.deyuanyun.pic.common.dto.PageJsonBean;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.ajax.AjaxSupport;
import com.deyuanyun.pic.common.util.converter.BeanConverter;
import com.deyuanyun.pic.common.util.web.Asserts;
import com.deyuanyun.pic.common.util.web.WebUtil;
import com.deyuanyun.pic.ctrl.controller.dto.ExinspTaskExpandDTO;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspADcMiorRecordQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspAnodesbedQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspAntiSurgeQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspBuriedDepthQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspCipsDcvgQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspCpPowerQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspCptestStationQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspDrainageQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspOcgradeQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspOclpointQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspPipeCorsTestQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspPipeSpanTestQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspReferenceQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.ExinspSoilCorrQuery;
import com.deyuanyun.pic.ctrl.controller.dto.exinsp.PipeBaseQuery;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspAcMiorRecordVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspAnodesbedVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspAntiSurgeVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspBuriedDepthVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspCipsDcvgVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspCpPowerVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspCpjumperVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspCptestStationVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspDcMiorRecordVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspDrainageVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspInsedJointVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspOcgradeVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspOclpointDigVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspOclpointVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspPcmAcvgVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspPipeCorsTestVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspPipeSpanTestVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspReferenceVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspSaalAnodeVO;
import com.deyuanyun.pic.ctrl.controller.vo.exinsp.ExinspSoilCorrVO;
import com.deyuanyun.pic.ctrl.domain.ExinspSoilCorr;
import com.deyuanyun.pic.ctrl.service.CoatDetectionService;
import com.deyuanyun.pic.ctrl.service.CpValidityService;
import com.deyuanyun.pic.ctrl.service.ExternalInspProjectService;
import com.deyuanyun.pic.ctrl.service.StrayCurrentService;
import com.github.pagehelper.Page;

/**
 * “外检数据” 管理控制类
 *
 * 方法详情：<br/>
 * 0.1，跳转到“外检任务”查询页面
 * 0.2，跳转到“外检数据”查询页面
 *
 * 1,“阴保有效性” 查询控制类
 * 1.1，测试桩检测数据 的分页查询与导出
 * 1.2，阴保电源检测记录 的分页查询与导出
 * 1.3，长效参比电极检测记录 的分页查询与导出
 * 1.4，辅助阳极地床检测记录 的分页查询与导出
 * 1.5，绝缘装置检测记录 的分页查询与导出
 * 1.6，防浪涌保护器检测记录 的分页查询与导出
 * 1.7，跨接线检测记录 的分页查询与导出
 * 1.8，牺牲阳极检测记录 的分页查询与导出
 * 1.9，排流装置检测记录 的分页查询与导出
 * 1.10，CIPS+DCVG检测记录 的分页查询与导出
 *
 * 2,“土壤腐蚀性评价”查询控制类
 * 2.1,土壤腐蚀性评价（土壤电阻率法） 的分页查询与导出
 *
 * 3 “杂散电流” 查询控制类
 * 3.1，交流干扰监测记录 的分页查询与导出
 * 3.2，直流干扰监测记录 的分页查询与导出
 *
 * 4，“涂层检测与评价” 查询控制类
 * 4.1，PCM、ACVG测试记录 的分页查询与导出
 * 4.2，外涂层漏损点信息 的分页查询与导出
 * 4.3，管道埋深测试记录 的分页查询与导出
 * 4.4，外涂层分级评价 的分页查询与导出
 * 4.5，管道穿越段测试记录 的分页查询与导出
 * 4.6，管道跨越段测试记录 的分页查询与导出
 * 4.7，外涂层漏损点开挖检测记录 的分页查询与导出
 *
 * @author huanglw
 * @date  2016-9-14
 *
 * History: [修改人][时间][修改描述]
 */
@Controller
@RequestMapping("/corrctrl")
public class ExternalDataMgrController extends BaseController {

    @Resource
    private CpValidityService cpValidityService;
    @Resource
    private StrayCurrentService strayCurrentService;
    @Resource
    private CoatDetectionService coatDetectionService;

    public final static String rootPath = "/template/excl/ctrl/";

    /**
     * 跳转到“外检任务”查询页面
     * @return
     */
    @RequestMapping("/external/toExternalList.html")
    public ModelAndView toExternalList() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("/corrctrl/external/externalList");
        return mav;
    }

    /**
     * 跳转到“外检数据”查询页面
     * @return
     */
    @RequestMapping("/external/toExternalData.html")
    public ModelAndView toExternalData(String exinspTaskId, ModelMap model) {
        ExinspTaskExpandDTO task = externalInspProjectService.getInfoById(exinspTaskId);
        model.addAttribute("task",task);
        return forword("/corrctrl/external/externalData",model);
    }



    /**
     * 根据条件 分页查询“阴保有效性”
     *
     * @param type
     *         cptestStation：测试桩检测数据
     *         cpPower：阴保电源检测记录
     *         reference：长效参比电极检测记录
     *         anodesbed：辅助阳极地床检测记录
     *         insedJoint：绝缘装置检测记录
     *         antiSurge：防浪涌保护器检测记录
     *         cpjumper：跨接线检测记录
     *         saalAnode：牺牲阳极检测记录
     *         drainage：排流装置检测记录
     *         cipsDcvg：CIPS+DCVG检测记录
     * @param request
     * @param <T>
     */
    @RequestMapping("/cpValidity/{type}/query.json")
    @ResponseBody
    public <T>void queryCpValidity(@PathVariable("type") String type, HttpServletRequest request) {
        PageJsonBean jsonBean = new PageJsonBean();
        jsonBean.setList(this.queryCpValidityVO(type, request.getParameterMap()));
        AjaxSupport.sendSuccessText("success", jsonBean);
    }

    // TODO 阴保有效性
    /**
     * 根据条件 导出“阴保有效性”各自对象
     *
     * @param type
     *         cptestStation：测试桩检测数据
     *         cpPower：阴保电源检测记录
     *         reference：长效参比电极检测记录
     *         anodesbed：辅助阳极地床检测记录
     *         insedJoint：绝缘装置检测记录
     *         antiSurge：防浪涌保护器检测记录
     *         cpjumper：跨接线检测记录
     *         saalAnode：牺牲阳极检测记录
     *         drainage：排流装置检测记录
     *         cipsDcvg：CIPS+DCVG检测记录
     * @param request
     */
    @RequestMapping("/cpValidity/{type}/export.json")
    @ResponseBody
    public void exportCpValidity(@PathVariable("type") String type,String exinspTaskId, HttpServletRequest request,HttpServletResponse response) throws IOException, ParseException {
        List list = this.queryCpValidityVO(type, request.getParameterMap());
        Map map = new HashMap();
        map.putAll(request.getParameterMap());
        map.put("data",list);
//        String[] columnKeys = this.getCpValidityColumnKeys(type);
        CpValiDityEnum exportEnum = CpValiDityEnum.getEnum(type);
        String downName = getDownName(exinspTaskId,exportEnum.getFileName());
        ExportExcel.getPathExportExcel(rootPath+exportEnum.getTempPath(),map,response,downName);
//        ExcelUtil.export(exportEnum.getFileName(), rootPath+exportEnum.getTempPath(), exportEnum.getBeginRow(), list, columnKeys);
    }

    public Page queryCpValidityVO(String type, Map map) {

        if (CpValiDityEnum.ExinspCptestStation.getType().equals(type)) {
            ExinspCptestStationQuery exinspCptestStationQuery = (ExinspCptestStationQuery) BeanConverter.toBean(map, ExinspCptestStationQuery.class);
            return new ExinspCptestStationVO().fromDomainList(cpValidityService.queryExinspCptestStation(exinspCptestStationQuery));
        }
        if (CpValiDityEnum.ExinspCpPower.getType().equals(type)) {
            ExinspCpPowerQuery exinspCpPowerQuery = (ExinspCpPowerQuery) BeanConverter.toBean(map, ExinspCpPowerQuery.class);
            return new ExinspCpPowerVO().fromDomainList(cpValidityService.queryExinspCpPower(exinspCpPowerQuery));
        }
        if (CpValiDityEnum.ExinspReference.getType().equals(type)) {
            ExinspReferenceQuery exinspReferenceQuery = (ExinspReferenceQuery) BeanConverter.toBean(map, ExinspReferenceQuery.class);
            return new ExinspReferenceVO().fromDomainList(cpValidityService.queryExinspReference(exinspReferenceQuery));
        }
        if (CpValiDityEnum.ExinspAnodesbed.getType().equals(type)) {
            ExinspAnodesbedQuery exinspAnodesbedQuery = (ExinspAnodesbedQuery) BeanConverter.toBean(map, ExinspAnodesbedQuery.class);
            return new ExinspAnodesbedVO().fromDomainList(cpValidityService.queryExinspAnodesbed(exinspAnodesbedQuery));
        }
        if (CpValiDityEnum.ExinspInsedJoint.getType().equals(type)) {
            ExinspReferenceQuery exinspReferenceQuery = (ExinspReferenceQuery) BeanConverter.toBean(map, ExinspReferenceQuery.class);
            return new ExinspInsedJointVO().fromDomainList(cpValidityService.queryExinspInsedJoint(exinspReferenceQuery));
        }
        if (CpValiDityEnum.ExinspAntiSurge.getType().equals(type)) {
            ExinspAntiSurgeQuery exinspAntiSurgeQuery = (ExinspAntiSurgeQuery) BeanConverter.toBean(map, ExinspAntiSurgeQuery.class);
            return new ExinspAntiSurgeVO().fromDomainList(cpValidityService.queryExinspAntiSurge(exinspAntiSurgeQuery));
        }
        if (CpValiDityEnum.ExinspCpjumper.getType().equals(type)) {
            ExinspReferenceQuery exinspReferenceQuery = (ExinspReferenceQuery) BeanConverter.toBean(map, ExinspReferenceQuery.class);
            return new ExinspCpjumperVO().fromDomainList(cpValidityService.queryExinspCpjumper(exinspReferenceQuery));
        }
        if (CpValiDityEnum.ExinspSaalAnode.getType().equals(type)) {
            ExinspReferenceQuery exinspReferenceQuery = (ExinspReferenceQuery) BeanConverter.toBean(map, ExinspReferenceQuery.class);
            return new ExinspSaalAnodeVO().fromDomainList(cpValidityService.queryExinspSaalAnode(exinspReferenceQuery));
        }
        if (CpValiDityEnum.ExinspDrainage.getType().equals(type)) {
            ExinspDrainageQuery exinspDrainageQuery = (ExinspDrainageQuery) BeanConverter.toBean(map, ExinspDrainageQuery.class);
            return new ExinspDrainageVO().fromDomainList(cpValidityService.queryExinspDrainage(exinspDrainageQuery));
        }
        if (CpValiDityEnum.ExinspCipsDcvg.getType().equals(type)) {
            ExinspCipsDcvgQuery exinspCipsDcvgQuery = (ExinspCipsDcvgQuery) BeanConverter.toBean(map, ExinspCipsDcvgQuery.class);
            return new ExinspCipsDcvgVO().fromDomainList(cpValidityService.queryExinspCipsDcvg(exinspCipsDcvgQuery));
        }
        return null;
    }

    public String[] getCpValidityColumnKeys(String type) {

        if (CpValiDityEnum.ExinspCptestStation.getType().equals(type)) {
            return new String[] {"pipeLineName", "testStationNum", "freeCorrosionPotential","onPotentialMax", "onPotentialMin",
                    "onPotentialAvg", "offPotentialMax", "offPotentialMin", "offPotentialAvg", "acInterferenceVoltage",
                    "soilResistivity", "acCurrentDensity", "degreeOfAcInterference","dcInterference","soilCorrosionGrade",
                    "protectingState", "testStationFineStatus", "testingDate", "testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspCpPower.getType().equals(type)) {
            return new String[] {"cppowerNum", "valveRoomName", "outputVoltage", "outputCurrent", "settingPotential",
                    "metricalPotential", "activeStated", "downBeginDate", "downEndDate", "downReason",
                    "grounding", "instrumentCalibration", "connectionCheck", "annualRepairRecord", "faultRecord",
                    "abnormal", "treatmentMeasures", "detectiongDete", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspReference.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "testStationNum", "lacationDescription",
                    "measuredReferencePotential", "standardReferencePotential", "measuredOpenPotential", "standardOpenPotential",
                    "maintenanceRecord", "faultRecord", "abnormal", "treatmentMeasures", "detectiongDete", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspAnodesbed.getType().equals(type)) {
            return new String[] {"customNumber", "testStationNum", "pipeValveroomName", "groundingResistance",
                    "maintenanceRecord", "faultRecord", "abnormal",  "",
                    "detectiongDete","recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspInsedJoint.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "testStationNum", "pipeValveroomName", "lacationDescription",
                    "mountingClass", "installationsite", "nonProtectivePotential",  "protectivePotential", "externalCurrent",
                    "innerCurrent", "faultRecord", "abnormal", "", "detectiongDete", "recordTime", "recorder", "remarks"};
        }
        if (CpValiDityEnum.ExinspAntiSurge.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "testStationNum", "pipeValveroomNanme", "locationDescription",
                    "nonProtectivePotential", "protectivePotential", "appearanceCheck",  "faultRecord", "abnormal",
                    "", "detectiongDete", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspCpjumper.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "testStationNum", "crosswireConnecttion", "crosswireDisConnection1",
                    "connectingPipeName1", "crosswireDisConnection2", "connectingPipeName2",  "crosswireDisConnection3", "connectingPipeName3",
                    "solderJointInspection", "faultRecord", "abnormal", "", "detectiongDete", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspSaalAnode.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "testStationNum", "onPotential", "sacalAnodeOpenPotential",
                    "currentOut", "groundingResistance", "soilResistivity",  "sacrificialAnodeMaintenance", "faultRecord",
                    "abnormal", "treatmentMeasures", "detectiongDete", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspDrainage.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "testStationNum", "interferenceType", "pipeToSoilPotential",
                    "acInterferenceVoltage", "drainageMax", "drainageMin",  "drainageAvg", "openCircuitPotential", "groundingResistance",
                    "faultRecord", "abnormal", "treatmentMeasures", "detectiongDete", "recorder", "recordTime", "remarks"};
        }
        if (CpValiDityEnum.ExinspCipsDcvg.getType().equals(type)) {
            return new String[] {"pipeLineName", "testStationNum", "detectionPointNumber", "oclpointId", "mileage",
                    "nagm", "nagmMileage", "cycle",  "cipsOnPotential", "cipsOffPotential", "dcvgOn", "dcvgOff", "dcvgIr",
                    "cathodicProtectionEvaluation", "testingDate", "testingCompany", "recorder", "recordTime", "remarks"};
        }
        return null;
    }

    public enum CpValiDityEnum {

        ExinspCptestStation("cptestStation", "测试桩检测数据.xlsx", "exinsp_cptest_station.xlsx", 5),
        ExinspCpPower("cpPower", "阴保电源检测记录.xlsx", "exinsp_cppower.xlsx", 4),
        ExinspReference("reference", "长效参比电极检测记录.xlsx", "exinsp_reference.xlsx", 4),
        ExinspAnodesbed("anodesbed", "辅助阳极地床检测记录.xlsx", "exinsp_anodesbed.xlsx", 3),
        ExinspInsedJoint("insedJoint", "绝缘装置检测记录.xlsx", "exinsp_insed_joint.xlsx", 4),
        ExinspAntiSurge("antiSurge", "防浪涌保护器检测记录.xlsx", "exinsp_anti_surge.xlsx", 3),
        ExinspCpjumper("cpjumper", "跨接线检测记录.xlsx", "exinsp_cpjumper.xlsx", 5),
        ExinspSaalAnode("saalAnode", "牺牲阳极检测记录.xlsx", "exinsp_saal_anode.xlsx", 3),
        ExinspDrainage("drainage", "排流装置检测记录.xlsx", "exinsp_drainage.xlsx", 4),
        ExinspCipsDcvg("cipsDcvg", "CIPS+DCVG检测记录.xlsx", "exinsp_cips_dcvg.xlsx", 4);

        private String type;
        private String fileName;
        private String tempPath;
        private Integer beginRow;

        private CpValiDityEnum(String type, String fileName, String tempPath, Integer beginRow) {
            this.type = type;
            this.fileName = fileName;
            this.tempPath = tempPath;
            this.beginRow = beginRow;
        }

        public String getType() {
            return type;
        }

        public String getFileName() {
            return fileName;
        }

        public String getTempPath() {
            return tempPath;
        }

        public Integer getBeginRow() {
            return beginRow;
        }

        public static CpValiDityEnum getEnum(String type) {
            CpValiDityEnum[] rs = CpValiDityEnum.values();
            for(int i=0,end=rs.length;i<end;i++) {
                if(rs[i].getType().equals(type)) {
                    return rs[i];
                }
            }
            return null;
        }

    }

    // TODO 土壤腐蚀性
    /**
     * 根据条件 分页查询“土壤腐蚀性评价（土壤电阻率法）”
     *
     * @param exinspSoilCorrQuery
     */
    @RequestMapping(value = "/soilCorr/query.json")
    @ResponseBody
    public void queryExinspSoilCorr(ExinspSoilCorrQuery exinspSoilCorrQuery) {
        PageJsonBean jsonBean = new PageJsonBean();
        Page<ExinspSoilCorr> exinspSoilCorrList = strayCurrentService.queryExinspSoilCorr(exinspSoilCorrQuery);
        jsonBean.setList(new ExinspSoilCorrVO().fromDomainList(exinspSoilCorrList));
        AjaxSupport.sendSuccessText("success", jsonBean);
    }

    /**
     * 根据条件导出“土壤腐蚀性评价（土壤电阻率法）”
     *
     * @return
     */
    @RequestMapping("/soilCorr/export.json")
    @ResponseBody
    public void exportExinspSoilCorr(ExinspSoilCorrQuery exinspSoilCorrQuery,HttpServletRequest request,HttpServletResponse response) throws IOException, ParseException {
        Page<ExinspSoilCorr> exinspSoilCorrList = strayCurrentService.queryExinspSoilCorr(exinspSoilCorrQuery);
        List<ExinspSoilCorrVO> exinspSoilCorrVOList = new ExinspSoilCorrVO().fromDomainList(exinspSoilCorrList);
        Map map = new HashMap();
        map.putAll(request.getParameterMap());
        map.put("data",exinspSoilCorrVOList);
//        String[] columnKeys = {"pipeLineName", "testStationNum", "soilResistivity","soilCorrosionRate",
//                "testingDate", "testingCompany", "recorder", "recordTime", "remarks"};
        String downName = getDownName(exinspSoilCorrQuery.getExinspTaskId(),"土壤腐蚀性评价（土壤电阻率法).xlsx");
        ExportExcel.getPathExportExcel(rootPath+"exinsp_soil_corr.xlsx",map,response,downName);
//        ExcelUtil.export("土壤腐蚀性评价（土壤电阻率法）.xlsx", rootPath+"exinsp_soil_corr.xlsx", 4, exinspSoilCorrVOList, columnKeys);
    }

    // TODO 杂散电流
    /**
     * 根据条件 分页查询“杂散电流”
     *
     * @param type
     *         ac：交流干扰监测记录
     *         dc：直流干扰监测记录
     * @param t 类型对于的阐述对象
     */
    @RequestMapping("/strayCurrent/{type}/query.json")
    @ResponseBody
    public void queryStrayCurrent(@PathVariable("type") String type, ExinspADcMiorRecordQuery t) {
        PageJsonBean jsonBean = new PageJsonBean();
        jsonBean.setList(this.queryStrayCurrentVO(type, t));
        AjaxSupport.sendSuccessText("success", jsonBean);
    }

    /**
     * 根据条件 查询“杂散电流”详情
     *
     * @param type
     *         ac：交流干扰监测记录
     *         dc：直流干扰监测记录
     * @param id 类型对应的id
     */
    @RequestMapping("/strayCurrent/{type}/find.json")
    @ResponseBody
    public void findStrayCurrent(@PathVariable("type") String type, String id) {

        if (StringUtils.isNullEmpty(id)) {
            AjaxSupport.sendSuccessText("success", null);
        }
        if (StrayCurrentEnum.ExinspAcMiorRecord.getType().equals(type)) {
            ExinspAcMiorRecordVO exinspAcMiorRecordVO = new ExinspAcMiorRecordVO();
            exinspAcMiorRecordVO.fromDomain(strayCurrentService.findExinspAcMiorRecord(id));
            AjaxSupport.sendSuccessText("success", exinspAcMiorRecordVO);
        }
        if (StrayCurrentEnum.ExinspDcMiorRecord.getType().equals(type)) {
            ExinspDcMiorRecordVO exinspDcMiorRecordVO = new ExinspDcMiorRecordVO();
            exinspDcMiorRecordVO.fromDomain(strayCurrentService.findExinspDcMiorRecord(id));
            AjaxSupport.sendSuccessText("success", exinspDcMiorRecordVO);
        }
        AjaxSupport.sendSuccessText("success", null);
    }

    /**
     * 根据条件 导出“杂散电流”各自对象
     *
     * @param type
     *         ac：交流干扰监测记录
     *         dc：直流干扰监测记录
     * @param t 类型对于的阐述对象
     */
    @RequestMapping("/strayCurrent/{type}/export.json")
    @ResponseBody
    public void exportStrayCurrent(@PathVariable("type") String type, ExinspADcMiorRecordQuery t,HttpServletRequest request,HttpServletResponse response) throws IOException, ParseException {
        List list = this.queryStrayCurrentVO(type, t);
        Map map = new HashMap();
        map.putAll(request.getParameterMap());
        map.put("data",list);
//        String[] columnKeys = this.getStrayCurrentColumnKeys(type);
        StrayCurrentEnum exportEnum = StrayCurrentEnum.getEnum(type);
        String downName = getDownName(t.getExinspTaskId(),exportEnum.getFileName());
        ExportExcel.getPathExportExcel(rootPath+exportEnum.getTempPath(),map,response,downName);
//        ExcelUtil.export(exportEnum.getFileName(), rootPath+exportEnum.getTempPath(), exportEnum.getBeginRow(), list, columnKeys);
    }

    /**
     * 根据条件 分页查询
     *
     * @param type
     *         ac：交流干扰监测记录
     *         dc：直流干扰监测记录
     * @param t 类型对于的阐述对象
     */
    public Page queryStrayCurrentVO(String type, ExinspADcMiorRecordQuery t) {
        if (StrayCurrentEnum.ExinspAcMiorRecord.getType().equals(type)) {
            return new ExinspAcMiorRecordVO().fromDomainList(strayCurrentService.queryExinspAcMiorRecord((ExinspADcMiorRecordQuery)t));
        }
        if (StrayCurrentEnum.ExinspDcMiorRecord.getType().equals(type)) {
            return new ExinspDcMiorRecordVO().fromDomainList(strayCurrentService.queryExinspDcMiorRecord((ExinspADcMiorRecordQuery)t));
        }
        return null;
    }

    public String[] getStrayCurrentColumnKeys(String type) {

        if (StrayCurrentEnum.ExinspAcMiorRecord.getType().equals(type)) {
            return new String[] {"pipeLineName", "monitorPointName", "customNumber","monitorPointType", "mileage", "nagm",
                    "nagmMileage", "locationDescription", "isType", "isName", "monitorDate","beginTime","endTime",
                    "readTimeInterval", "maxAcVoltage","minAcVoltage","avgAcVoltage","soilResistivity",
                    "acCurrentDensity", "acInterferenceVoltage", "repairSuggestion", "latestRepairTime","repairState",
                    "testingDate", "testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (StrayCurrentEnum.ExinspDcMiorRecord.getType().equals(type)) {
            return new String[] {"pipeLineName", "monitorPointName", "customNumber","monitorPointType", "mileage", "nagm",
                    "nagmMileage", "locationDescription", "isType", "isName", "monitorDate","beginTime","endTime",
                    "readTimeInterval", "maxOffset","minOffset","positiveMeanOffset","negativeMeanOffset",
                    "soilResistivity", "positivein850Ratio", "positivein800Ratio","positivein750Ratio", "positivein0Ratio",
                    "acInterferenceVoltage", "repairSuggestion", "latestRepairTime","repairState", "testingCompany",
                    "testingDate", "recorder", "recordTime", "remarks"};
        }
        return null;
    }

    public enum StrayCurrentEnum {

        ExinspAcMiorRecord("ac", "交流干扰监测记录.xlsx", "exinsp_ac_mior_record.xlsx", 4),
        ExinspDcMiorRecord("dc","直流干扰监测记录.xlsx", "exinsp_dc_mior_record.xlsx", 4);

        private String type;
        private String fileName;
        private String tempPath;
        private Integer beginRow;

        private StrayCurrentEnum(String type,String fileName, String tempPath, Integer beginRow) {
            this.type = type;
            this.fileName = fileName;
            this.tempPath = tempPath;
            this.beginRow = beginRow;
        }

        public String getType() {
            return type;
        }

        public String getFileName() {
            return fileName;
        }

        public String getTempPath() {
            return tempPath;
        }

        public Integer getBeginRow() {
            return beginRow;
        }

        public static StrayCurrentEnum getEnum(String type) {
            StrayCurrentEnum[] rs = StrayCurrentEnum.values();
            for(int i=0,end=rs.length;i<end;i++) {
                if(rs[i].getType().equals(type)) {
                    return rs[i];
                }
            }
            return null;
        }
    }

    // TODO 涂层检测与评价
    /**
     * 根据条件 分页查询
     *
     * @param type
     *         pcmAcvg：PCM、ACVG测试记录
     *         oclpoint：外涂层漏损点信息
     *         buriedDepth：管道埋深测试记录
     *         ocgrade：外涂层分级评价
     *         pipeCorsTest：管道穿越段测试记录
     *         pipeSpanTest：管道跨越段测试记录
     *         oclpointDig：外涂层漏损点开挖检测记录
     * @param request
     * @param <T>
     */
    @RequestMapping("/coatDetection/{type}/query.json")
    @ResponseBody
    public <T>void queryCoatDetection(@PathVariable("type") String type, HttpServletRequest request) {
        PageJsonBean jsonBean = new PageJsonBean();
        jsonBean.setList(this.queryCoatDetectionVO(type, request.getParameterMap()));
        AjaxSupport.sendSuccessText("success", jsonBean);
    }

    /**
     * 根据条件 导出各自对象
     *
     * @param type
     *         pcmAcvg：PCM、ACVG测试记录
     *         oclpoint：外涂层漏损点信息
     *         buriedDepth：管道埋深测试记录
     *         ocgrade：外涂层分级评价
     *         pipeCorsTest：管道穿越段测试记录
     *         pipeSpanTest：管道跨越段测试记录
     *         oclpointDig：外涂层漏损点开挖检测记录
     * @param request
     */
    @RequestMapping("/coatDetection/{type}/export.json")
    @ResponseBody
    public void exportCoatDetection(@PathVariable("type") String type,String exinspTaskId,HttpServletRequest request,HttpServletResponse response) throws IOException, ParseException {
        List list = this.queryCoatDetectionVO(type, request.getParameterMap());
        Map map = new HashMap();
        map.putAll(request.getParameterMap());
        map.put("data",list);
//        String[] columnKeys = this.getCoatDetectionColumnKeys(type);
        CoatDetectionEnum exportEnum = CoatDetectionEnum.getEnum(type);
        String downName = getDownName(exinspTaskId,exportEnum.getFileName());
        ExportExcel.getPathExportExcel(rootPath+exportEnum.getTempPath(),map,response,downName);
//        ExcelUtil.export(exportEnum.getFileName(), rootPath+exportEnum.getTempPath(), exportEnum.getBeginRow(), list, columnKeys);
    }

    /**
     * 根据条件 分页查询
     *
     * @param type
     *         pcmAcvg：PCM、ACVG测试记录
     *         oclpoint：外涂层漏损点信息
     *         buriedDepth：管道埋深测试记录
     *         ocgrade：外涂层分级评价
     *         pipeCorsTest：管道穿越段测试记录
     *         pipeSpanTest：管道跨越段测试记录
     *         oclpointDig：外涂层漏损点开挖检测记录
     * @param map 类型对于的阐述对象
     */
    public Page queryCoatDetectionVO(String type, Map map) {
        if (CoatDetectionEnum.ExinspPcmAcvg.getType().equals(type)) {
            PipeBaseQuery baseQuery = (PipeBaseQuery) BeanConverter.toBean(map, PipeBaseQuery.class);
            return new ExinspPcmAcvgVO().fromDomainList(coatDetectionService.queryExinspPcmAcvg(baseQuery));
        }
        if (CoatDetectionEnum.ExinspOclpoint.getType().equals(type)) {
            ExinspOclpointQuery exinspOclpointQuery = (ExinspOclpointQuery) BeanConverter.toBean(map, ExinspOclpointQuery.class);
            return new ExinspOclpointVO().fromDomainList(coatDetectionService.queryExinspOclpoint(exinspOclpointQuery));
        }
        if (CoatDetectionEnum.ExinspBuriedDepth.getType().equals(type)) {
            ExinspBuriedDepthQuery exinspBuriedDepthQuery = (ExinspBuriedDepthQuery) BeanConverter.toBean(map, ExinspBuriedDepthQuery.class);
            return new ExinspBuriedDepthVO().fromDomainList(coatDetectionService.queryExinspBuriedDepth(exinspBuriedDepthQuery));
        }
        if (CoatDetectionEnum.ExinspOcgrade.getType().equals(type)) {
            ExinspOcgradeQuery exinspOcgradeQuery = (ExinspOcgradeQuery) BeanConverter.toBean(map, ExinspOcgradeQuery.class);
            return new ExinspOcgradeVO().fromDomainList(coatDetectionService.queryExinspOcgrade(exinspOcgradeQuery));
        }
        if (CoatDetectionEnum.ExinspPipeCorsTest.getType().equals(type)) {
            ExinspPipeCorsTestQuery exinspPipeCorsTestQuery = (ExinspPipeCorsTestQuery) BeanConverter.toBean(map, ExinspPipeCorsTestQuery.class);
            return new ExinspPipeCorsTestVO().fromDomainList(coatDetectionService.queryExinspPipeCorsTest(exinspPipeCorsTestQuery));
        }
        if (CoatDetectionEnum.ExinspPipeSpanTest.getType().equals(type)) {
            ExinspPipeSpanTestQuery exinspPipeSpanTestQuery = (ExinspPipeSpanTestQuery) BeanConverter.toBean(map, ExinspPipeSpanTestQuery.class);
            return new ExinspPipeSpanTestVO().fromDomainList(coatDetectionService.queryExinspPipeSpanTest(exinspPipeSpanTestQuery));
        }
        if (CoatDetectionEnum.ExinspOclpointDig.getType().equals(type)) {
            PipeBaseQuery pipeBaseQuery = (PipeBaseQuery) BeanConverter.toBean(map, PipeBaseQuery.class);
            return new ExinspOclpointDigVO().fromDomainList(coatDetectionService.queryExinspOclpointDig(pipeBaseQuery));
        }
        return null;
    }

    public String[] getCoatDetectionColumnKeys(String type) {

        if (CoatDetectionEnum.ExinspPcmAcvg.getType().equals(type)) {
            return new String[] {"pipeLineName", "testStationNum", "detectionPointNumber","oclpointNum", "mileage",
                    "fieldTestAbsoluteDistance","relativeTestPileDistance", "electricCurrent",  "buriedDepth",
                    "dbValue","testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CoatDetectionEnum.ExinspOclpoint.getType().equals(type)) {
            return new String[] {"pipeLineName", "customNumber", "mileage","nagm", "nagmMileage",
                    "locationDescription", "buriedDepth", "dbValue",  "irValue", "onPotential", "offPotential",
                    "acInterference", "dcInterference", "faultGrade", "repairSuggestion", "latestRepairTime",
                    "repairState","testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CoatDetectionEnum.ExinspBuriedDepth.getType().equals(type)) {
            return new String[] {"pipeLineName", "testStationNum", "detectionPointNumber","mileage", "nagm",
                    "nagmMileage", "buriedDepth", "evaluationOfLayingCondition",  "repairMeasures",
                    "testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CoatDetectionEnum.ExinspOcgrade.getType().equals(type)) {
            return new String[]{"pipeLineName", "beginStationNumber", "endStationNumber","evaluationOfPipeLength",
                    "leakagePointNumber", "pvalue", "coatingGrade",  "testingMethod",
                    "testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CoatDetectionEnum.ExinspPipeCorsTest.getType().equals(type)) {
            return new String[]{"pipeLineName", "crossingName", "upStationNumber","downStationNumber",
                    "locationDescription", "upStreamPotential", "downStreamPotential",  "antiCorrLayerInsuResis",
                    "evalOfAntiCorrLayer", "cathodicProtectionEvaluation", "faultRecord", "abnormal", "treatmentMeasures",
                    "testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CoatDetectionEnum.ExinspPipeSpanTest.getType().equals(type)) {
            return new String[] {"pipeLineName", "spanningSegmentName", "upStationNumber","downStationNumber",
                    "locationDescription",  "spanningSegmentLength", "upStreamPotential",  "downStreamPotential",
                    "appeInspOfAntiCorrLayer", "faultRecord", "abnormal", "treatmentMeasures",
                    "testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        if (CoatDetectionEnum.ExinspOclpointDig.getType().equals(type)) {
            return new String[] {"pipeLineName", "oclpointNum", "mileage","nagm", "nagmMileage",
                    "locationDesc",  "terrainGeomorphoDesc", "groundWater", "soilResistivity", "oclpointLength",
                    "oclpointWidth", "oclpointClock", "oclpointDescription", "freeCorrPotential","tubeGroundPotential",
                    "polarizedPotential", "acPotential", "appearance", "test1","test2",
                    "test3", "test4", "peelTest1", "peelTest2","peelTest3", "peelTest4",
                    "testVoltage", "amount", "soilColor","soilHumidity", "soilCompactness", "deeprootedPlants",
                    "soilPh", "redoxPotential","moistureContent", "saltContent", "chlorideion", "sulfateion",
                    "testingDate","testingCompany", "recorder", "recordTime", "remarks"};
        }
        return null;
    };

    public enum CoatDetectionEnum {

        ExinspPcmAcvg("pcmAcvg", "PCM、ACVG测试记录.xlsx", "exinsp_pcm_acvg.xlsx", 4),
        ExinspOclpoint("oclpoint", "外涂层漏损点信息.xlsx", "exinsp_oclpoint.xlsx", 4),
        ExinspBuriedDepth("buriedDepth", "管道埋深测试记录.xlsx", "exinsp_buried_depth.xlsx", 4),
        ExinspOcgrade("ocgrade", "外涂层分级评价.xlsx", "exinsp_ocgrade.xlsx", 4),
        ExinspPipeCorsTest("pipeCorsTest", "管道穿越段测试记录.xlsx", "exinsp_pipe_cors_test.xlsx", 4),
        ExinspPipeSpanTest("pipeSpanTest", "管道跨越段测试记录.xlsx", "exinsp_pipe_span_test.xlsx", 4),
        ExinspOclpointDig("oclpointDig", "外涂层漏损点开挖检测记录.xlsx", "exinsp_oclpoint_dig.xlsx", 5);


        private String type;
        private String fileName;
        private String tempPath;
        private Integer beginRow;

        private CoatDetectionEnum(String type, String fileName, String tempPath, Integer beginRow) {
            this.type = type;
            this.fileName = fileName;
            this.tempPath = tempPath;
            this.beginRow = beginRow;
        }

        public String getType() {
            return type;
        }

        public String getFileName() {
            return fileName;
        }

        public String getTempPath() {
            return tempPath;
        }

        public Integer getBeginRow() {
            return beginRow;
        }

        public static CoatDetectionEnum getEnum(String type) {
            CoatDetectionEnum[] rs = CoatDetectionEnum.values();
            for(int i=0,end=rs.length;i<end;i++) {
                if(rs[i].getType().equals(type)) {
                    return rs[i];
                }
            }
            return null;
        }

    }
    
    
    /****CK的代码------开始*****/
    private @Resource ExternalInspProjectService externalInspProjectService;
    protected Logger logger = LogManager.getLogger(this.getClass());
    @RequestMapping("/external/toExcelData.json")
    @ResponseBody
    public void toExcelData(@RequestParam("repairTaskId") String repairTaskId,ModelMap model,HttpServletRequest request,HttpServletResponse response) {
        /*
        String fileUploadDir = Globals.getProperties("file_tmp_dir");
        Asserts.assertTrue(StringUtils.isNotEmpty(fileUploadDir), "系统初始化配置错误：没有获取到临时文件保存目录。");
        String filePath = "zip" + repairTaskId;
        File zipFile = new File(fileUploadDir + "/" + filePath);
        zipFile.mkdirs();
        */
        try {
            ExinspTaskExpandDTO exinspTaskExpand = externalInspProjectService.getInfoById(repairTaskId);
            Asserts.assertTrue(exinspTaskExpand != null, "没有找到外检项目！");
            WebUtil.setDownHeader(exinspTaskExpand.getName() + "检测数据表" + StringUtils.convertDateToString(new Date(), "yyyyMMdd") + ".zip");
            OutputStream os = response.getOutputStream();
            ZipOutputStream zos = new ZipOutputStream(os);
            //zos.setEncoding("GBK");
            //zos.setComment("请全部解压后查看");
            
            //阴保有效性
            CpValiDityEnum[] cpValiDityEnums = CpValiDityEnum.values();
            for (int i = 0; i < cpValiDityEnums.length; i++) {
                CpValiDityEnum exportEnum = cpValiDityEnums[i];
                try {
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("exinspTaskId", repairTaskId);
                    List list = this.queryCpValidityVO(exportEnum.getType(), map);
//                    String[] columnKeys = this.getCpValidityColumnKeys(exportEnum.getType());
                    String tempPath = rootPath+exportEnum.getTempPath();
                    
                    //List<Map> mapList = BeanConverter.toListMap(list);
                    Map downMap = new HashMap();
                    downMap.putAll(request.getParameterMap());
                    downMap.put("data",list);
                    downMap.put("fileName",exportEnum.getFileName());
                    Workbook workbook = ExportExcel.exportExcelToZip(rootPath+exportEnum.getTempPath(),downMap,response,exportEnum.getFileName());
//                    Workbook workbook = ExcelUtil.initWorkbook(tempPath, columnKeys, mapList, exportEnum.getBeginRow());
                    this.zipPutExcel("阴保有效性/" + exportEnum.getFileName() , workbook, zos);
                } catch (Exception e) {
                    logger.error("打包的时候，生成“" + exportEnum.getFileName() + "”失败！", e);
                }
            }
            
            //土壤腐蚀
            try {
                ExinspSoilCorrQuery exinspSoilCorrQuery = new ExinspSoilCorrQuery();
                exinspSoilCorrQuery.setExinspTaskId(repairTaskId);
                Page<ExinspSoilCorr> exinspSoilCorrList = strayCurrentService.queryExinspSoilCorr(exinspSoilCorrQuery);
                List<ExinspSoilCorrVO> exinspSoilCorrVOList = new ExinspSoilCorrVO().fromDomainList(exinspSoilCorrList);
//                String[] columnKeys_soil = {"pipeLineName", "testStationNum", "soilResistivity","soilCorrosionRate",
//                        "testingDate", "testingCompany", "recorder", "recordTime", "remarks"};
                //List<Map> mapList_soil = BeanConverter.toListMap(exinspSoilCorrVOList);
                Map soilMap = new HashMap();
                soilMap.putAll(request.getParameterMap());
                soilMap.put("data",exinspSoilCorrVOList);
                soilMap.put("fileName","土壤腐蚀性评价（土壤电阻率法)");
                Workbook workbook_soil = ExportExcel.exportExcelToZip(rootPath+"exinsp_soil_corr.xlsx",soilMap,response,"土壤腐蚀性评价（土壤电阻率法).xlsx");
//                Workbook workbook_soil = ExcelUtil.initWorkbook(rootPath+"exinsp_soil_corr.xlsx", columnKeys_soil, mapList_soil, 5);
                this.zipPutExcel("土壤腐蚀性/土壤腐蚀性评价（土壤电阻率法）.xlsx" , workbook_soil, zos);
                
            } catch (Exception e) {
                logger.error("打包的时候，生成“土壤腐蚀性评价（土壤电阻率法）.xlsx”失败！", e);
            }
            
            
            //杂散电流
            StrayCurrentEnum[] strayCurrentEnums = StrayCurrentEnum.values();
            ExinspADcMiorRecordQuery exinspADcMiorRecordQuery = new ExinspADcMiorRecordQuery();
            exinspADcMiorRecordQuery.setExinspTaskId(repairTaskId);
            for (int i = 0; i < strayCurrentEnums.length; i++) {
                StrayCurrentEnum exportEnum = strayCurrentEnums[i];
                try {
                    String type = exportEnum.getType();
                    List list = this.queryStrayCurrentVO(type, exinspADcMiorRecordQuery);
//                    String[] columnKeys = this.getStrayCurrentColumnKeys(type);
                    
                    List<Map> mapList = BeanConverter.toListMap(list);
                    Map currentMap  = new HashMap();
                    currentMap.putAll(request.getParameterMap());
                    currentMap.put("data",mapList);
                    currentMap.put("fileName",exportEnum.getFileName());
                    Workbook workbook = ExportExcel.exportExcelToZip(rootPath+exportEnum.getTempPath(),currentMap,response,exportEnum.getFileName());
//                    Workbook workbook = ExcelUtil.initWorkbook(rootPath+exportEnum.getTempPath(), columnKeys, mapList, exportEnum.getBeginRow());
                    this.zipPutExcel("杂散电流干扰/" + exportEnum.getFileName() , workbook, zos);
                } catch (Exception e) {
                    logger.error("打包的时候，生成“" + exportEnum.getFileName() + "”失败！", e);
                }
                
            }
            
            
            //涂层检测与评价
            CoatDetectionEnum[] coatDetectionEnums = CoatDetectionEnum.values();
            for (int i = 0; i < coatDetectionEnums.length; i++) {
                CoatDetectionEnum exportEnum = coatDetectionEnums[i];
                try {
                    String type = exportEnum.getType();
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("exinspTaskId", repairTaskId);
                    List list = this.queryCoatDetectionVO(type, map);
//                    String[] columnKeys = this.getCoatDetectionColumnKeys(type);

                    //List<Map> mapList = BeanConverter.toListMap(list);
                    Map coatMap = new HashMap();
                    coatMap.putAll(request.getParameterMap());
                    coatMap.put("data",list);
                    coatMap.put("fileName",exportEnum.getFileName());
                    Workbook workbook = ExportExcel.exportExcelToZip(rootPath+exportEnum.getTempPath(),coatMap,response,exportEnum.getFileName());
//                    Workbook workbook = ExcelUtil.initWorkbook(rootPath+exportEnum.getTempPath(), columnKeys, mapList, exportEnum.getBeginRow());
                    this.zipPutExcel("涂层检测与评价/" + exportEnum.getFileName() , workbook, zos);
                } catch (Exception e) {
                    logger.error("打包的时候，生成“" + exportEnum.getFileName() + "”失败！", e);
                }
                
            }
            
            zos.closeEntry();
            zos.close();
        } catch (Exception e) {
            Asserts.assertTrue(false, "系统错误：打包Excel失败。具体：" + e.getMessage());
        }
        
    }

//    private void getFileName(Map map,String fileName)
//    {
//        map.put("fileName",fileName.substring(0,fileName.lastIndexOf(".")));
//    }

    private void zipPutExcel(String fileName,Workbook workbook,ZipOutputStream zos){
        try {
            ZipEntry ze = new ZipEntry(fileName);
            ByteArrayOutputStream b = new ByteArrayOutputStream();
            workbook.write(b);
            int len = b.size();
            ze.setSize((long)len);
            zos.putNextEntry(ze);
            zos.write( b.toByteArray() );
        } catch (Exception e) {
            //按理说这个地方应该是不会出现异常的，所以直接try不处理。
            logger.error("把Excel压入Zip的时候出现异常！", e);
        }
        
        
    }
    /****CK的代码------结束*****/
    private String getDownName(String exinspTaskId,String fileName) throws ParseException {
        Asserts.assertTrue(null != exinspTaskId,"外检任务id未获取！");
        String downName = null;
        ExinspTaskExpandDTO task = externalInspProjectService.getInfoById(exinspTaskId);
        if(null != task ){
            downName = task.getName()+fileName.substring(0,fileName.lastIndexOf("."));
        }
        return downName;
    }
}
